package com.example.test2018131530.controller;

import com.example.test2018131530.bean.UserBean;
import com.example.test2018131530.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpSession;

@Controller
public class LoginController {
    @Autowired
    UserService userService;
    @RequestMapping("/login")
    public String show(){
        return "login";
    }
    @RequestMapping(value = "/loginln",method = RequestMethod.POST)
    public String login(String name, String password, HttpSession session){
        UserBean userBean = userService.loginln(name,password);
        if(userBean!=null){
            session.setAttribute("user",userBean);
            return "success";
        }else{
            return "error";
        }
    }
}
